<template>
    <el-dialog :visible.sync="show" title="修改信息" width="30%">
        <div class="hidden-sm-and-down">
            <el-form ref="elForm" :model="updateForm" :rules="rules" label-width="100px" size="medium">
               <!-- <el-form-item  label="主键"  prop="id"> 
                    <el-input v-model="updateForm['id']" style="width: 100%"
                              clearable placeholder="请输入主键">
                    </el-input>
                </el-form-item> -->
                <el-form-item  label="社团名称"  prop="name"> 
                    <el-input v-model="updateForm['name']" style="width: 100%"
                              clearable placeholder="请输入社团名称">
                    </el-input>
                </el-form-item>
                <!-- <el-form-item  label="创建时间"  prop="setupTime"> 
                    <el-input v-model="updateForm['setupTime']" style="width: 100%"
                              clearable placeholder="请输入创建时间">
                    </el-input>
                </el-form-item> -->
                <el-form-item  label="限制人数"  prop="proprieter"> 
                    <el-input v-model="updateForm['proprieter']" style="width: 100%"
                              clearable placeholder="请输入限制人数">
                    </el-input>
                </el-form-item>
                <el-form-item  label="社团主题"  prop="proprieterPhone"> 
                    <el-input v-model="updateForm['proprieterPhone']" style="width: 100%"
                              clearable placeholder="请输入社团主题">
                    </el-input>
                </el-form-item>
                <el-form-item  label="社团图片id"  prop="imgId"> 
                    <el-input v-model="updateForm['imgId']" style="width: 100%"
                              clearable placeholder="请输入社团图片id">
                    </el-input>
                </el-form-item>
                <el-form-item  label="类型"  prop="type"> 
                    <el-input v-model="updateForm['type']" style="width: 100%"
                              clearable placeholder="请输入类型">
                    </el-input>
                </el-form-item>
                <el-form-item  label="社团简介"  prop="introduce"> 
                    <el-input v-model="updateForm['introduce']" style="width: 100%"
                              clearable placeholder="请输入简介">
                    </el-input>
                </el-form-item>
               <!-- <el-form-item  label="社团展示视频"  prop="video"> 
                    <el-input v-model="updateForm['video']" style="width: 100%"
                              clearable placeholder="请输入社团展示视频">
                    </el-input>
                </el-form-item> -->
                <el-form-item  label="公告"  prop="announcement"> 
                    <el-input v-model="updateForm['announcement']" style="width: 100%"
                              clearable placeholder="请输入">
                    </el-input>
                </el-form-item>
                <el-form-item size="large">
                    <el-button type="primary" @click="submitForm">提交</el-button>
                    <el-button @click="resetForm">重置</el-button>
                    <el-button type="primary" @click="organizationUpdateClose">取消</el-button>
                    <br>
                    <span style="color: #00ffff;">{{ message }}</span>
                </el-form-item>
            </el-form>
        </div>
    </el-dialog>
</template>
<script>
import {updateOrganization} from "@/api/organizationServer";
export default {
    name: 'organizationUpdate',
    components: {},
    data() {
        return {
            show: false,
            updateForm:{
                "id":null,
                "name":null,
                "setupTime":null,
                "proprieter":null,
                "proprieterPhone":null,
                "imgId":null,
                "type":null,
                "introduce":null,
                "video":null,
                "announcement":null,
            },
            msg:{
                "id":null,
                "name":null,
                "setupTime":null,
                "proprieter":null,
                "proprieterPhone":null,
                "imgId":null,
                "type":null,
                "introduce":null,
                "video":null,
                "announcement":null,
            },
            message: '',
            id: 0,
            rules: {},
        }
    },
    computed: {},
    mounted() {
        this.$bus.$on('organizationUpdateOpen', this.organizationUpdateOpen)      // 显示更新会话
        this.$bus.$on('organizationUpdateClose', this.organizationUpdateClose)    // 关闭更新会话
    },
    beforeCreate() {
        this.$bus.$off('organizationUpdateOpen')
        this.$bus.$off('organizationUpdateClose')
    },
    methods: {
		//提交成功提示
		open1() {
		        this.$notify({
		          title: '成功',
		          message: '修改成功',
		          type: 'success'
		        });
		},
        organizationUpdateOpen(msg) {
            this.msg = msg
            this.resetForm()
            this.show = true
        },
        organizationUpdateClose() {
            this.show = false
        },
        // 提交表单
        submitForm() {
            updateOrganization(this.updateForm).then(response => {
                response    // 处理响应
                // 更新成功，提交表格
                this.$bus.$emit('organizationUpDataTable', this.Value)
				this.open1()
            })
        },
        // 重置表单
        resetForm() {
            this.updateForm.id = this.msg["id"]
            this.updateForm.name = this.msg["name"]
            this.updateForm.setupTime = this.msg["setupTime"]
            this.updateForm.proprieter = this.msg["proprieter"]
            this.updateForm.proprieterPhone = this.msg["proprieterPhone"]
            this.updateForm.imgId = this.msg["imgId"]
            this.updateForm.type = this.msg["type"]
            this.updateForm.introduce = this.msg["introduce"]
            this.updateForm.video = this.msg["video"]
            this.updateForm.announcement = this.msg["announcement"]
        },
    }
}
</script>
<style>
.el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
}
</style>
